package com.nondo.dean.platform.controller.api.inner;

import com.nondo.dean.common.web.View;
import com.nondo.dean.platform.domain.Customer;
import com.nondo.dean.platform.model.result.CustomerResult;
import com.nondo.dean.platform.service.CustomerService;
import com.nondo.dean.platform.tool.DateProcessUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xiaofan
 * @Description:
 * @throws
 * @date 2018-05-1813:50
 * @Version
 */
@RestController("apiInnerCustomer")
@RequestMapping("/{v}/inner/customer")
public class CustomerController {

    @Autowired
    CustomerService customerService;


    /**
     * 获取单个客户信息
     * @param id
     * @return
     */
    @RequestMapping("/select/{id}")
    public View<CustomerResult> getCustomer(@PathVariable("id") Integer id){
        CustomerResult customerResult = new CustomerResult();
        View<CustomerResult> view = new View<>(20000,"获取成功");
        Customer customer = customerService.selectCustomer(id);
        customerResult.setName(customer.getName());
        customerResult.setPhone(customer.getPhone());
        customerResult.setCreateDate(DateProcessUtils.formatDate(customer.getCreateDate(),DateProcessUtils.YMDHMS_BREAK));
        customerResult.setUpdateDate(DateProcessUtils.formatDate(customer.getUpdateDate(),DateProcessUtils.YMDHMS_BREAK));
        view.setData(customerResult);
        return view;
    }

}
